package com.kotlin.tsw.usercenter.presenter

import com.kotlin.tsw.baselibrary.ext.execute
import com.kotlin.tsw.baselibrary.persenter.BasePresenter
import com.kotlin.tsw.baselibrary.rx.BaseSubScriber
import com.kotlin.tsw.usercenter.data.protocol.UserInfo
import com.kotlin.tsw.usercenter.presenter.view.LoginView
import com.kotlin.tsw.usercenter.presenter.view.RegisterView
import com.kotlin.tsw.usercenter.service.UserService
import javax.inject.Inject

class LoginPersenter @Inject constructor(): BasePresenter<LoginView>(){
    @Inject
    lateinit var userService : UserService

    fun login(mobile: String, pwd: String,pushId:String) {
        /*
        * 业务逻辑
        * */
//        val userService = UserServiceImpl()
        if(!checkNetWork()){
            mView.onErorr("网络不可用")
            return
        }

        mView.showLoading()
        userService.login(mobile,pwd,pushId)
                .execute(object :BaseSubScriber<UserInfo>(mView){
                    override fun onNext(t: UserInfo) {
                            mView.onLoginResult(t)
                    }
                },lifecycleProvider)
//        mView.onRegisterResult(true)
    }
}